package net.lzzy.springboot_chapter04_thymeleaf.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class LoginController {
    @GetMapping("/login")
    public String login() {
        return "login";
    }

    @PostMapping("/logincheck")
    public String loginIn(@RequestParam("username") String username, @RequestParam("password") String password){
        if (username.equals("xxx") && password.equals("123"))
            return "redirect:/index";
        else
            return "login";
    }
}
